package com.example.a10928.weifriend.ui.home.menu

import android.content.ClipData
import android.content.ClipboardManager
import android.databinding.ObservableArrayList
import android.databinding.ViewDataBinding
import android.support.v7.widget.LinearLayoutManager
import com.example.a10928.weifriend.App.app
import com.example.a10928.weifriend.R
import com.example.a10928.weifriend.adapter.ServiceAdapter
import com.example.a10928.weifriend.databinding.ActivityServiceBinding
import com.example.a10928.weifriend.http.api.base.CustomerServiceBean
import com.example.a10928.weifriend.ui.DatabindingBaseActivity
import com.example.a10928.weifriend.util.L
import com.example.a10928.weifriend.util.RxUtil
import kotlinx.android.synthetic.main.activity_service.*

class ServiceActivity : DatabindingBaseActivity() {

    override fun bindingInitData() {
    }

    override fun bindingInitView(viewDataBinding: ViewDataBinding?) {
        setTitleText(ThemeEnum.Back_Default, "客服中心")
        val mBinding = viewDataBinding as ActivityServiceBinding
        getData( mBinding)

//        service_qq_one.setOnClickListener {
//            val myClipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
//            val myClip: ClipData
//            myClip = ClipData.newPlainText("qq", list[0].qq_account)
//            myClipboard.primaryClip = myClip
//            L.t("复制成功")
//        }
//
//
//        service_vx_one.setOnClickListener {
//            val myClipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
//            val myClip: ClipData
//            myClip = ClipData.newPlainText("wx", list[0].wx_account)
//            myClipboard.primaryClip = myClip
//            L.t("复制成功")
//        }
//
//        service_tel_one.setOnClickListener {
//            val myClipboard = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
//            val myClip: ClipData
//            myClip = ClipData.newPlainText("tel", list[0].tel_number)
//            myClipboard.primaryClip = myClip
//            L.t("复制成功")
//        }
    }

    override fun bindingGetContentView(): Int {
        return R.layout.activity_service
    }

    private fun getData(mBinding:ActivityServiceBinding) {
        app().bpService.customerService
                .compose(RxUtil.io2mainLoad(this))
                .subscribe(
                        { r ->
                            mBinding.serviceRv.adapter = ServiceAdapter(R.layout.item_service_data,r.data.customer_service)
                            mBinding.serviceRv.layoutManager = LinearLayoutManager(this)
                        }, {
                    RxUtil::errorException
                }
                )
    }
}